package lab01;

import java.util.Scanner;

public class Test12 {
    public static void main(String[] args) {
        int individual;
        int decade;
        int hundreds;
        int thousand;
        Scanner figure = new Scanner(System.in);
        System.out.println("请输入一个1~9999之间的数：");
        int num = figure.nextInt();
        if (num<1 || num>9999) {
            System.out.println("您输入的数不在1~9999之间！");
        }else{
            thousand = num / 1000;
            hundreds = (num % 1000)/100;
            decade = (num%100)/10;
            individual = num%10;
            if (thousand > 0) {
                System.out.println("这是一个4位数。");
                if (thousand==individual) {
                    if (hundreds==decade) {
                        flipConut();
                    }else {
                        unflipConut();
                    }
                }else {
                    unflipConut();
                }
            }else if (hundreds>0) {
                System.out.println("这是一个3位数。");
                if (hundreds==individual) {
                    flipConut();
                }else {
                    unflipConut();
                }
            }else if (decade>0) {
                System.out.println("这是一个2位数。");
                if (decade==individual) {
                    flipConut();
                }else {
                    unflipConut();
                }
            }else {
                System.out.println("这是一个1位数。");
                flipConut();
            }
        }
    }

    static void flipConut() {
        System.out.println("这是一个回文数！");
    }

    static void unflipConut() {
        System.out.println("这不是一个回文数。");
    }
}

